<html>
 <head> 
  <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
  <title>图书馆喧哗反馈系统</title> 
  <script src="js/jq.js"></script> 
 </head> 
 <body id="v1"> 
  <meta id="v2" charset="UTF-8"> 
  <meta id="v3" name="viewport" content="width=device-width, initial-scale=1.0"> 
  <style id="v4">
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #f0f0f0;
        }
        .top-image {
            position: absolute;
            top: 20px;
            left: 20px;
            z-index: 10;
            width: 300px;
            height: auto;
            border: 2px solid #333;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
    </style> 
  <script src="js/jq.js"></script> 
  <img id="v6" src="./pictures/library.jpg" alt="示例图片" class="top-image"> 
  <!--以上是图片展示(记得格式化代码，不然乱七八糟的)--> 
  <style id="v7">
        body {
            margin: 0;
            padding: 0;
            height: 200vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #f5f5f5;
            font-family: Arial, sans-serif;
        }

        .form-container {
            background-color: #ffffff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }

        .input-group {
            margin-bottom: 20px;
        }

        .input-group label {
            display: block;
            margin-bottom: 5px;
            font-size: 14px;
            color: #333;
        }

        .input-group select,
        .input-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
            color: #333;
            background-color: #f9f9f9;
            transition: border-color 0.3s ease;
        }

        .input-group select:focus,
        .input-group input:focus {
            border-color: #007bff;
            outline: none;
            background-color: #fff;
        }

        .submit-button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        .submit-button:hover {
            background-color: #0056b3;
        }
    </style> 
  <script src="js/jq.js"></script> 
  <div id="v9" class="form-container"> 
   <div id="v10" class="input-group"> 
    <label id="v11" for="option">选择选项</label> 
    <select id="option" name="option"> <option id="v12" value="option1">桌Z1</option> <option id="v13" value="option2">桌Z2</option> <option id="v14" value="option3">桌Z3</option> <option id="v15" value="option4">桌Z4</option> <option id="v16" value="option5">桌Z5</option> <option id="v17" value="option6">桌Z6</option> <option id="v18" value="option7">桌Z7</option> <option id="v19" value="option0">桌Z8</option> <option id="v20" value="option9">桌Z9</option> </select> 
   </div> 
   <div id="v21" class="input-group"> 
    <label id="v22" for="input1">投诉内容</label> 
    <input type="text" id="input1" name="input1" placeholder="请输入内容(喧哗，打闹等)"> 
   </div> 
   <div id="v23" class="input-group"> 
    <label id="v24" for="input2">您的有效联系方式</label> 
    <input type="text" id="input2" name="input2" placeholder="请输入内容(电话号码，微信，QQ，邮箱等)"> 
   </div> 
   <a href="./do.html">
   <button a href="./do.html" id="submit" type="submit" class="submit-button" >提交</button>
   </a> 
  </div> 
  <!--运行之后，图片的那一层居然会跑，不知道是什么问题，难道是至于的层数有问题?用了绝对定位好像还是出问题，也不知道是哪里问题--> 
  <script>
    document.getElementById('submit').addEventListener('click', function () {
        const selectedOption = document.getElementById('option').value;
        const input1Value = document.getElementById('input1').value;
        const input2Value = document.getElementById('input2').value;

        const queryString = `deskname=${encodeURIComponent(selectedOption)}&act=${encodeURIComponent(input1Value)}&user=${encodeURIComponent(input2Value)}`;

        const url = `./mail/api.php?${queryString}`;

        const xhr = new XMLHttpRequest();

        xhr.open('GET', url, true); // 初始化一个 GET 请求

        xhr.onload = function () {
            if (xhr.status >= 200 && xhr.status < 300) {
                console.log('请求成功:', xhr.responseText);
                webtools-static-lert('提交成功！'); // 弹出提示框告知用户提交成功(也不知道哪里的问题，为什么弹窗就是弹不出来呢)
            } else {
                console.error('请求失败:', xhr.statusText);
                webtools-static-lert('提交失败，请重试！');
            }
        };

        xhr.onerror = function () {
            console.error('请求出错！');
            webtools-static-lert('提交失败，请检查网络！');
        };

        xhr.send();
    }); 
</script>  
 </body>
</html>